<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" class="notie"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>点击统计</title> 
</head> 
<body>
<a data-clk="1" href="http://www.douban.com">douban</a>
<a data-clk="2" href="http://www.douban.com"><div>douban</div></a>
<a data-clk="3" href="http://www.douban.com"><img src="http://www.pmme.cn/upload/douban_top_right.GIF" /></a>

<a data-clk="4" href="http://www.douban.com"><div></div><img src="http://www.pmme.cn/upload/douban_top_right.GIF" /></div></a>


<script type="text/javascript">
(function(){
	//阻止默认事件
	function stopDefault(e) {
	    //阻止默认浏览器动作(W3C)
	    if ( e && e.preventDefault )
	        e.preventDefault();
	    //IE中阻止函数器默认动作的方式
	    else
	        window.event.returnValue = false;
	    return false;
	}
	//阻止冒泡
	function stopPropagation(e){
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
	}
	
	
	//发送统计
	
	function dostati(data){
		console.log(data);
	}
	
	//监听点击事件
	document.onclick = function(e){	
		var targ,node;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;
		
		stopDefault(e);
		//get praentNode is A	
		var ancestorNode = function(el, tagName) {
			tagName = tagName.toUpperCase();
			while(el.tagName != tagName) {
				el = el.parentNode;
			}
			return el;
		};
				
		if(targ.nodeName !== 'A' && targ.nodeName !== 'HTML' && targ.nodeName !== 'BODY') {
			node = ancestorNode(targ,'a');
		}else{ 
			node = targ;
		}
		
		var attr = node.getAttribute('data-clk');
		var data = {};
		data.location = document.location.href;
		data.href = node.getAttribute('href');
		data.clk = attr;
		if(attr){
			dostati(data);
		}
	}

}());


</script>
</body>
</html>